package bmatch.tech.file.resource;

import bmatch.tech.file.model.Response;
import bmatch.tech.file.service.MyDirectoryService;
import bmatch.tech.file.service.impl.MyDirectoryServiceImpl;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

@Path("directory")
public class MyDirectoryResource {

    private static MyDirectoryService service;
    static {
        service = new MyDirectoryServiceImpl();
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("upload")
    public Response create(
            @QueryParam("userId") String userId,
            @QueryParam("path") String path,
            @QueryParam("name") String name) {

        Response response = service.create(userId,path,name);
        return response;
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("delete")
    public Response delete(@QueryParam("userId") String userId,
                           @QueryParam("path") String path,
                           @QueryParam("name") String name) {
        Response response = service.delete(userId,path,name);
        return response;
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("rename")
    public Response rename(@QueryParam("userId") String userId,
                           @QueryParam("path") String path,
                           @QueryParam("originalName") String originalName,
                           @QueryParam("targetName") String targetName) {
        Response response = service.rename(userId,path,originalName,targetName);
        return response;
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("shift")
    public Response shift(@QueryParam("userId") String userId,
                          @QueryParam("name") String name,
                          @QueryParam("originalPath") String originalPath,
                          @QueryParam("targetPath") String targetPath) {
        Response response = service.shift(userId,name,originalPath,targetPath);
        return response;
    }


}
